
(function () { 
	Codestrong.ui.CreateExamMain = function () {

//var LectureMain = function() {
	var aps='';
	if(Ti.Platform.osname== 'android') {
  		 Titanium.include('../globals.js');
  		// Titanium.include('../cs/cs.js');
  		// Titanium.include('../cs/ui.js');
  		// Titanium.include('../windows/EventGarbageCollection.js');
  		 aps='../';
    }
    else {
   		  Titanium.include('globals.js');
   		//  Titanium.include('cs/cs.js');
   		//  Titanium.include('cs/ui.js');
   		  //Titanium.include('windows/EventGarbageCollection.js');
    }
    /////////////////////EVENT//////////
	var data = []; 
	var response;
    ////////////////////////////////////FUNTION///////////////////////
    ////////////////////////////////////////////////////////////
        
    var win = Titanium.UI.createWindow({
            id: 'ExamMain',
            title: 'THI TRỰC TUYẾN',
            backgroundColor: '#FFF',
            barColor: '#414444',
            fullscreen: false
           
        });
       
    var egc = new globals.EventGarbageCollection(win);
	
	
	egc.addEventListener('ExamMain:CreateExamDetail', function(data) {
		
		Codestrong.navGroup.open(Codestrong.ui.CreateExamBySubject({
    	    IDMon:data.IDMon,
    	    TenMonHoc:data.TenMonHoc,
		}), 
		{
		    animated: true,
		    navBarHidden:true
		});				
    })
    egc.addEventListener('back_ExamMain', function () {
    	Codestrong.navGroup.close(win, {
                        animated: true
        });
	});
  
	////////////main_header///////////////////////////
	 var databutton_right=[
    	//{Id:1,Image:aps+'images/list_bullets.png',Image_:aps+'images/list_bullets_.png',tag:'Category'},
	    {Id:2,Image:aps+'images/account.png',Image_:aps+'images/account_.png',tag:'Login'},
	    //{Id:3,Image:aps+'images/search.png',Image_:aps+'images/search_.png',tag:'Search'},
	    
	]
	var main_header=require('controls/main_header').main_header({
	 		backgroundImage: aps+'images/panel3.png',
	 		headertext:'Thầy trò Mobile: Thi trực tuyến',
		    left: 0,
		    top: 0,
		    height:65,
		    width:'100%',//Globals.platformWidth,
		    touchEnabled: true		,
		     databutton_right:databutton_right,
		    imback:   aps+'images/back.png',
		    imback_:   aps+'images/back_.png',
		  	idWinParent:'ExamMain',
		    
    })

	win.add(main_header);
  
        
        
	
	///////////////////////////////////////////////////////////
	ScrollViewMain = Ti.UI.createScrollView({
		top:main_header.height
	});
	
	
	
	
	
	
	
	/////////////////////////////////////////////////////////////
	
	var db = require('db');
	var Items_Lop = db.getExam();
	var heighttable=113//130
	//var data = [{title:'CPF Cloud Login', hasChild:true, url:'tmlogin.html'}];  


	var topview=0;
	
	for (var i = 0; i < Items_Lop.length; i++) {
		 var datablock = [];
		 var dataimage = [];
		 var dataMonHoc = [];
		 var dataID = [];
		 var IdLop= Items_Lop[i].Id;
		 var TenLop= Items_Lop[i].Name;
		 var Items_MonHoc = db.getExamDetail(IdLop);

		 for (var j = 0; j < Items_MonHoc.length; j++) {
		 	datablock[j] = Items_MonHoc[j].Name;
		 	dataimage[j] = aps+'images/'+Items_MonHoc[j].Images;
		 	dataID[j] = Items_MonHoc[j].Id;
		 	dataMonHoc[j] = Items_MonHoc[j];
		 }
		
		 
		var height_tableblock=Math.round((datablock.length/2))*heighttable
	
		var Exam_blocksubject=require('controls/Exam_blocksubject').Exam_blocksubject({
		  			 heightview:45,
					 widthview:'100%',//Globals.platformWidth,
					 leftview:0,
		  			 topview:topview,
		  			 infolabel:TenLop,
		  			 width_viewheader:'100%',//Globals.platformWidth,
		  			 height_viewheader:45,
		  			 backgroundImage_viewheader:aps+'images/panel.png',
		  			 datablock:datablock,
		  			 dataimage:dataimage,
		  			 dataID:dataID,
		  			 dataMonHoc:dataMonHoc,
		  			 height_tableblock:height_tableblock,
		  			 height_table:heighttable,
		  			 backgroundImageTable:aps+'images/bgTable.png',
		  			// backgroundImageSection:aps+'images/bgTable.png',
		  			 backgroundColorSection:'#2981a3'
		  			 //urljson:Globals.serviceurl_GetListLectureTopNew,
			    })
	
		ScrollViewMain.add(Exam_blocksubject);
		topview=topview+Exam_blocksubject.height
	
	}
	
	
	
	win.add(ScrollViewMain);
	
	win.addEventListener('open', function(e)
	{
	  
	});
	
	
	//return win;
//};

//module.exports = LectureMain;




 return win;
       
    };
})();